import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/19 16:30
 * @description 统计每只怪兽到达的时间，如果在同一时间有多只怪兽到达，那么主角挂，
 */
public class Solution {
    public static void main(String[] args) {
        Solution so = new Solution();
        int[] dist = {4, 3, 3, 3, 4}, speed = {1, 1, 1, 1, 4};
        so.eliminateMaximum(dist, speed);
    }
    public int eliminateMaximum(int[] dist, int[] speed) {
        // 统计每只 sb到达时间
        int[] cnt = new int[(int) 1e5 + 10];
        int n = dist.length;
        for (int i = 0; i < n; i++) {
            // 向上去整
            int time = dist[i] / speed[i];
            int arriveTime = dist[i] % speed[i] == 0 ? time : time + 1;
            cnt[arriveTime]++;
        }
        int sum = 0;
        for (int i = 0; i < (int) 1e5; i++) {
            sum += cnt[i];
            // i时间只能消灭 i只
            if (sum > i) {
                return i;
            }
        }
        return n;
    }
}
